<template>
  <div>
    <alert v-model="show" title="提示" @on-show="onShow" @on-hide="onHide">{{message}}</alert>
    <Yq-header :needBack="true">
      <p slot="content">兑换记录</p>
    </Yq-header>
    <group gutter="0" style="padding-top: 38px;">
      <flexbox :gutter="0" v-for="recordList in recordList">
        <flexbox-item ><div class="flex-cash">
          <cell :title="recordList.startTime"><span style="color: black">- {{recordList.point}}</span></cell>
          <cell gutter="0" style="padding: 0"></cell>
        </div></flexbox-item>
      </flexbox>
    </group>
  </div>
</template>

<script>
  import { Group, Cell, XButton, XInput, Flexbox, FlexboxItem, Alert } from 'vux'
  import * as urls from '../../../../api/urls'
  import YqHeader from '../../../../components/YqHeader.vue'

  export default {
    components: {
      Group,
      Cell,
      XButton,
      XInput,
      Flexbox,
      FlexboxItem,
      Alert,
      YqHeader
    },
    data () {
      return {
        show: false,
        message: '',
        recordList: [
          {
            startTime: '2017-02-03 16:01',
            point: 300
          }, {
            startTime: '2017-02-03 16:01',
            point: 200
          }
        ]
      }
    },
    methods: {
      onHide () {
        console.log('on hide')
      },
      onShow () {
        console.log('on show')
      },
      getPointRecord () {
        let userId = this.$store.state.userInfo.id
        let that = this
        that.http(urls.pointRecord, {userId: userId}, function (res) {
          if (res.status === 100) {
            that.recordList = res.data.data.list
          } else {
            that.show = true
            that.message = res.errMsg
          }
        }, function (res) {
          that.show = true
          that.message = res.errMsg
        })
      },
      weixinfn17 () {
        let that = this
        let userId = this.$store.state.userInfo.id
        let logo = this.$store.state.empower.LOGO
        let url = window.location.origin
        let link = url + '/api/wxAuth/index?type=t1' + '&uid=' + userId
        that.$wechat.onMenuShareAppMessage({
          title: '孝行通', // 分享标题
          desc: '孝行通·微商城 一个让子女为父母尽孝的老年服务平台', // 分享描述
          link: link, // 分享链接
          imgUrl: logo, // 分享图标
          success: function () {
            // 用户确认分享后执行的回调函数
          },
          cancel: function () {
            // 用户取消分享后执行的回调函数
          }
        })
        that.$wechat.onMenuShareTimeline({
          title: '孝行通', // 分享标题
          link: link, // 分享链接
          imgUrl: logo, // 分享图标
          success: function () {
            // 用户确认分享后执行的回调函数
          },
          cancel: function () {
            // 用户取消分享后执行的回调函数
          }
        })
      }
    },
    mounted: function () {
      this.getPointRecord()
      this.weixinfn17()
    }
  }
</script>

<style scoped="scoped" lang="less">
  .flex-cash{
    text-align: left;
    background-clip: padding-box;
  }
  .flex-cash > p{
    font-size: 15px;
    text-align: right;
    margin: -5px 15px 5px 0;
  }
</style>
